package ro.gateway.aida.obj;

/**
 * <p>Title: Romanian AIDA</p> <p>Description: </p> <p>Copyright: Copyright (comparator) 2003</p> <p>Company:
 * ro-gateway</p>
 *
 * @author Mihai Popoaei, mihai_popoaei@yahoo.com, smike@intellisource.ro
 * @version 1.0-* @version $Id: AIDALocation.java,v 1.1 2004/10/24 23:37:10 mihaipostelnicu Exp $
 */
public class AIDALocation extends AIDAActivityObject {
     private int cregion_id;
     private CRegion cregion;
     private Country country;
     private int reg_id = -1;
     private int jud_id = -1;
     private int sirsup_id = -1;
     private int siruta_id = -1;
     private Region region;
     private County judet;
     private Town oras;
     private Village localitate;

     public AIDALocation() {
          this.objectType = TYPE_LOCATION;
     }

     public int getCregion_id() {
          return cregion_id;
     }

     public void setCregion_id( int cregion_id ) {
          this.cregion_id = cregion_id;
     }

     public CRegion getCregion() {
          return cregion;
     }

     public void setCregion( CRegion cregion ) {
          this.cregion = cregion;
          if (cregion != null) {
               this.cregion_id = cregion.getId();
          } else {
               this.cregion_id = -1;
          }
     }

     public void setCountry( Country country ) {
          this.country = country;
     }

     public Country getCountry() {
          return country;
     }

     public void setReg_id( int reg_id ) {
          this.reg_id = reg_id;
     }

     public int getReg_id() {
          return reg_id;
     }

     public void setJud_id( int jud_id ) {
          this.jud_id = jud_id;
     }

     public int getJud_id() {
          return jud_id;
     }

     public void setSirsup_id( int sirsup_id ) {
          this.sirsup_id = sirsup_id;
     }

     public int getSirsup_id() {
          return sirsup_id;
     }

     public void setSiruta_id( int siruta_id ) {
          this.siruta_id = siruta_id;
     }

     public int getSiruta_id() {
          return siruta_id;
     }

     public void setRegion( Region region ) {
          this.region = region;
          if ( region == null ) {
               this.reg_id = -1;
          } else {
               this.reg_id = region.getId();
          }
     }

     public Region getRegion() {
          return region;
     }

     public void setJudet( County judet ) {
          this.judet = judet;
          if ( judet == null ) {
               this.jud_id = -1;
          } else {
               jud_id = judet.getId();
          }
     }

     public County getJudet() {
          return judet;
     }

     public void setOras( Town oras ) {
          this.oras = oras;
          if ( oras == null ) {
               this.sirsup_id = -1;
          } else {
               this.sirsup_id = oras.getSirsup_id();
          }
     }

     public Town getOras() {
          return oras;
     }

     public void setLocalitate( Village localitate ) {
          this.localitate = localitate;
          if ( localitate == null ) {
               this.siruta_id = -1;
          } else {
               this.siruta_id = localitate.getSiruta_id();
          }
     }

     public Village getLocalitate() {
          return localitate;
     }

     public boolean equals( AIDALocation location ) {
          boolean eq = ( location.getReg_id() == this.getReg_id() ) &&
             ( location.getJud_id() == this.getJud_id() ) &&
             ( location.getSirsup_id() == this.getSirsup_id() ) &&
             ( location.getSiruta_id() == this.getSiruta_id() ) &&
             ( location.getCregion_id() == this.getCregion_id() );
          if ( !eq ) return false;
          if ( ( this.country == null ) && ( location.country == null ) ) {
               return true;
          }
          if ( country != null ) {
               return country.equals( location.country );
          } else {
               return location.country.equals( country );
          }
     }

     public String toString() {
          StringBuffer sb = new StringBuffer();

          sb.
             append( this.getCountry() ).
             append( ":" ).
             append( this.getJud_id() ).
             append( ":" ).
             append( this.getSirsup_id() ).
             append( ":" ).
             append( this.getSiruta_id() ).
             append( "." );

          return sb.toString();
     }
}